<div>
	<input type="hidden" name="{$name}" value="{$value}" />
	<ul class="weui-uploader__files">
	    {notempty name="image"}
	        <li class="weui-uploader__file" style="background-image: url(/uploads/picture/{$image.path})"></li>
	    {/notempty}
	</ul>
    <div class="weui-uploader__input-box" id="uploader_{$id}"></div>
</div>
<script type="text/javascript">
	$(function(){
		var uploader_{$id} = WebUploader.create({
			swf: '__JS__/plugins/webuploader/Uploader.swf',
			server: "{:url('core/File/uploadPicture')}",
			pick: "#uploader_{$id}",
			resize: false
		});

		uploader_{$id}.on('fileQueued', function(file) {
			uploader_{$id}.upload();
			toast.showLoading();
		});
		uploader_{$id}.on('uploadSuccess', function(file, ret) {
			if ( ret.status==1 ) {
				toast.success("上传成功");
                // $('#uploader_{$id}').prev().find("li").css("background-image", "url("+ret.data.file.url+")");
                $('#uploader_{$id}').prev().html('<li onclick="javascript: remove_file_{$id}();" class="weui_uploader__file" style="float: left; margin-right: 9px; margin-bottom: 9px; width: 79px; height: 79px; background: no-repeat center center; background-size: cover; background-image: url(' + ret.data.file.url + ')"></li>');
				$('input[name={$name}]').val(ret.data.file.id);
			} else { // 上传失败
				toast.error("上传失败"+ret.info);
			}
		});
		uploader_{$id}.on('uploadError', function(file) {
			toast.error("上传失败");
		});
		uploader_{$id}.on('uploadComplete', function(file) {
		 	toast.hideLoading();
		});

		$("#uploader_{$id}").find(".webuploader-pick").last().css({
			width: "77px",
			height: "77px"
		});
	});
	function remove_file_{$id}(obj, attachId) {
		$('#uploader_{$id}').val('');
		$(obj).parent('div').remove();
	}
</script>